Permanently Mount External USB Hard Drive
Though external hard drives may work plugged directly into your Raspberry Pi, it's probably not a great idea, since you don't want to draw too much current through the Pi. You'll almost certainly want to use other peripherals (WiFi at least), so use a powered USB hub. I use a Plugable 4-port hub, which I found at Amazon. Mount USB Drive (non-NTFS) Once you have the device plugged connected, first make sure that your Pi recognizes the drive. Run sudo blkid This should show your drive associated with some /dev/XXX. If not, you may want to reboot your Pi. You can check the drive's size and partitions using sudo fdisk -l This shows my 1.5TB hard drive is located at /dev/sda1. Now create a new folder to mount your drive to: sudo mkdir /mnt sudo mkdir /mnt/mydrivename You'll also want to change the permissions on the new mount folder sudo chmod 775 /mnt/mydrivename This combination (775) provides read, write, execute permissions to all the current user and group, and only read, execute permissions to the rest of the world. Here's a link showing various chmod configurations. To mount it, run sudo mount /dev/XXX /mnt/mydrivename where you should replace "XXX" with the proper drive location you found when running the fdisk command, and "mydrivename" can be changed to your preference. Also, "/mnt" is a customary folder for mounting drives, but you can choose/create any folder you'd like. You should now be able to browse the drive, etc. Now see what's in the drive. cd /mnt/mydrivename dir You should be able to see the contents of your drive. Try creating a new folder here. mkdir testfolder dir If you see your new folder "testfolder" listed, you've successfully mounted the drive. If not, (like me) you may have an NTFS drive, and you'll need to go about things differently. Mount NTFS Drive If you had a NTFS drive like mine, it should be indicated when you ran blkid under the "TYPE" information. If so, also take note of the "UUID" shown here. You'll need this. You'll need to install some new software: sudo apt-get install ntfs-3g Also, check to see if your Raspberry Pi automounted the drive in the /media folder: dir /media In this case, you may be able to stop here and just use this drive location. If you'd like to learn an alternative, continue reading. If your drive showed up in the /media folder, you should unmount it using: sudo umount /media/XXX where "XXX" should be replaced with whatever your drive was called in the /media folder. (Note also, if you already completed the first section to mount non-NTFS drive, you'll also want to unmount the drive in the /mnt folder you created.) Create a new folder for your drive and set the correct permissions, as done in the previous section. Now mount the drive using your newly-installed ntfs-3g software: sudo mount -t ntfs-3g -o uid=pi,gid=pi /dev/XXX /mnt/mydrivename This tells the Pi that the type (-t) is ntfs-3g and should be mounted for users (uid) and groups (uid) name "pi". If you have no errors, you should now be able to browse the drive, etc. Now see what's in the drive. cd /mnt/mydrivename dir You should be able to see the contents of your drive. Try creating a new folder here. mkdir testfolder dir If you see your new folder "testfolder" listed, you've successfully mounted the drive. Automount Drive on Boot Once you've created a place to mount your drive, and given it the appropriate permissions, you'll need to edit one file to make sure that the Pi mounts your drive each time it boots. Run sudo nano /etc/fstab At the end of the list, you'll want to add one line with information for your new drive: /dev/XXX /mnt/myfoldername ntfs-3g uid=pi,gid=pi 0 0 Each entry should be separated with a tab. It should end up looking like this. Save the file (Ctrl+X) and reboot. You should now immediately be able to browse the new drive. dir /mnt/mydrivename Category:Raspberry Pi Category:Mount